package com.qidian.mes.qc.controller;

import com.qidian.mes.pojo.Defect;
import com.qidian.mes.qc.service.DefectService;
import com.qidian.mes.util.pojo.MESResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@CrossOrigin
@RequestMapping("/defect")
public class DefectController {
    @Autowired
    private DefectService defectService;

    @GetMapping("/get")
    public MESResult get(Long defectId) {
        return defectService.queryById(defectId);
    }
    @GetMapping("/list")
    public MESResult list(@RequestParam(defaultValue = "1")int page, @RequestParam(defaultValue = "10") int limit, Defect defect){
        System.out.println("=========================="+defect);
        return defectService.list(page,limit,defect);
    }
    @PostMapping("/save")
    public MESResult save(@RequestBody Defect defect) {
        return defectService.save(defect);
    }
    @PutMapping("/update")
    public MESResult update(@RequestBody Defect defect) {
        return defectService.update(defect);
    }

    @DeleteMapping("/{defectId}")
    public MESResult deleteById(@PathVariable Long defectId) {
        return defectService.deleteByDefectId(defectId);
    }
    @DeleteMapping("/deletes")
    public MESResult deletesByDefectId(Long[] defectId) {

        return defectService.deletesByDefectIds(defectId);

    }
    }
